package producer

import (
	"context"
	"gitee.com/lailonghui/vehicle-supervision-framework/pkg/asserts"
	"github.com/streadway/amqp"
)

var publishChannel *amqp.Channel

func NewProducer(ctx context.Context, conn *amqp.Connection) {
	var err error
	publishChannel, err = conn.Channel()
	asserts.Nil(err, err)
}

// 发布消息
func Publish(ctx context.Context, exchange, key string, mandatory, immediate bool, publishing amqp.Publishing) error {
	return publishChannel.Publish(exchange, key, mandatory, immediate, publishing)
}
